package com.zou.mall.platform.controller;

import com.zou.common.utils.R;
import com.zou.mall.platform.manage.MailManager;
import com.zou.mall.platform.pojo.MailCondition;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

/**
 * @author leonard
 * @date 2022/5/10
 * @Description TODO
 */
@Slf4j
@Controller
public class SmsController {

    @Resource
    MailManager mailManager;

    @GetMapping(value = "/sms/sendEmail")
    public R sendEmail(@RequestParam("email") String email, @RequestParam("code") String code) {
        log.info("email:{} code:{}",email,code);
        MailCondition mailCondition = new MailCondition();
        mailCondition.setFrom("leonard_zou@163.com");
        mailCondition.setTo(email);
        mailCondition.setSubject("your check code from mall98");
        mailCondition.setText("code: "+code);
        mailManager.sendMail(mailCondition);
        return new R();
    }
}
